package com.zzl.study.demo.utils;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 日期时间工具类
 *
 * @author: zhangzl
 * @date: 2025/10/14 15:30
 * @version: 1.0
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DateTimeUtil {

    /**
     * 日期时间格式化器
     */
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    /**
     * 将日期时间转换为字符串
     *
     * @param date 日期时间
     * @return 字符串
     */
    public static String toDateString(LocalDateTime date) {
        if (date == null) {
            return "";
        }
        return date.format(FORMATTER);
    }

}
